package com.ebs.md.fxmonitor.marketmonitor.alert;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/alert/FlashingMessageCreator.java $
 *  $Revision: #1 $  $Change: 115130 $  $DateTime: 2012/09/23 15:32:42 $  $Author: Aviad.Yosef $
 */

import java.util.List;

import com.ebs.market.monitor.MarketMonitor.EventType;
import com.ebs.market.monitor.MarketMonitor.FlashingEvent;
import com.ebs.market.monitor.MarketMonitor.MarketIdentfier;
import com.ebs.market.monitor.MarketMonitor.OrderDetail;
import com.ebs.md.fxmonitor.marketmonitor.model.FlashSingleFact;


public class FlashingMessageCreator
extends           AbstractAlertMessageCreatorBySingleFact<FlashingEvent, FlashSingleFact>
{

	public FlashingMessageCreator(List<FlashSingleFact> dataList) {
		super(dataList);
	}

	@Override
	public FlashingEvent createAlertObject() {
		FlashingEvent.Builder builder = FlashingEvent.newBuilder();

		final FlashSingleFact firstDataElement = getFirstDataElement();
		{
		MarketIdentfier mi = gpbBuildMarketIdentifier(firstDataElement.getPair());
		builder.setMarketId(mi);
		}
		final String eventId = createEventIdByQuoteId(firstDataElement, firstDataElement.getTimestamp());
		builder.setEventId(eventId);
		builder.setEventTime(eventTimeMillis);
		builder.setConfigInstanceName(firstDataElement.getConfigInstanceName());
		{
		OrderDetail od = gpbBuildOrderDetail(firstDataElement);
		builder.setFirstQuote(od);
		}
		
		// set causing Quote IDs
		for ( FlashSingleFact curr : dataList ) {
			builder.addQuoteIds(curr.getQuoteId());
		}
		
		return builder.build();
	}

	@Override
	public EventType getEventType() {
		return EventType.FLASHING;
	}

}
